<include file="Public/header" title="可疑人员管理"/>

<div id="page-wrapper">

    <div class="row">
        <div class="col-md-2">
            <a href="{:U('Index/multi')}" class="btn btn-success">批量录入</a>
        </div>
        <div class="col-md-2">
            <a href="{:U('Index/single')}" class="btn btn-success">单条录入</a>
        </div>
        <div class="col-md-4">
            <form action="{:U('Index/index')}" method="post">
                <div class="form-group input-group">
                    <input type="text" class="form-control" name="key" placeholder="输入姓名或者身份证号关键词搜索">
                    <span class="input-group-btn">
                      <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    <table class="info-table">
        <thead>
        <tr>
            <th width="7%">姓名</th>
            <th width="6%">性别</th>
            <th width="6%">民族</th>
            <th width="30%">实际地址</th>
            <th width="10%">人员类型</th>
            <th width="5%">风险等级</th>
            <th width="8%">管辖民警</th>
            <th width="10%">布控状态</th>
            <th width="12%">操作</th>
            <th width="7%">详细信息</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="model" item="v">
            <tr>
                <td>
                    {$v.name}
                </td>

                <if condition="$v.sex eq 1">
                    <td>男</td>
                    <else/>
                    <td>女</td>
                </if>

                <if condition="$v.mz eq NULL">
                    <td>无</td>
                    <else/>
                    <td>{$v.mz}</td>
                </if>

                <if condition="$v.resident_current eq NULL">
                    <td>无</td>
                    <else/>
                    <td>{$v.resident_current}</td>
                </if>

                <td>{$v.type}</td>

                <if condition="$v.risk_grade eq NULL">
                    <td>无</td>
                    <else/>
                    <td>{$v.risk_grade}</td>
                </if>

                <if condition="$v.polices eq NULL">
                    <td>无</td>
                    <else/>
                    <td>{$v.polices}</td>
                </if>

                <if condition="$v.bk_status eq 0">
                    <td>
                        <span class="label label-danger">布控</span>
                    </td>

                    <td>
                        <a href="##"style="color:#428BCA;"onclick='changeStatus("{$v.id}",1)'>停止</a> | <a href="##" style="color:red;" onclick='changeStatus("{$v.id}",2)'>结束</a> | <a href="##" style="color:dodgerblue;" onclick='changeStatus("{$v.id}",3)'>删除</a>
                    </td>

                    <else/>

                    <if condition="$v.bk_status eq 1">
                        <td>
                            <span class="label label-success">停止</span>
                        </td>
                        <td>
                            <a href="##" style="color:#50AD1E;" onclick='changeStatus("{$v.id}",0)'>布控</a> | <a href="##" style="color:red;" onclick='changeStatus("{$v.id}",2)'>结束</a> | <a href="##" style="color:dodgerblue;" onclick='changeStatus("{$v.id}",3)'>删除</a>
                        </td>
                        <else/>
                        <td>
                            <span class="label label-info">结束</span>
                        </td>
                        <td>
                            <a href="##" style="color:#50AD1E;" onclick='changeStatus("{$v.id}",0)'>布控</a> | <a href="##"style="color:#428BCA;"onclick='changeStatus("{$v.id}",1)'>停止</a> | <a href="##" style="color:dodgerblue;" onclick='changeStatus("{$v.id}",3)'>删除</a>
                        </td>
                    </if>

                </if>

            <td>
                <a href="{:U('Index/info?key=')}{$v.id}" style="color:dodgerblue">
                    查看
                </a>
            </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="clearfix"></div>
    {$page}
</div>

<script src="__STATIC__/js/dialog-min.js"></script>
<script type="text/javascript">
    function changeStatus(id, status) {

        switch (status){
            case 0:
            case 1:
            case 2:
                var d = dialog({
                    title: '提示',
                    width: 200,
                    content: '您将更改布控状态',
                    okValue: '确定',
                    ok: function () {
                        this.title('更新中...');

                        $.ajax({
                            url: "{:U('Index/changestatus')}",
                            type: 'post',
                            dataType: 'json',
                            timeout: 80000,
                            data: {
                                id: id,
                                status: status
                            },
                            success: function (data) {
                                if (data.status) {
                                    window.location.reload();
                                }
                                else {
                                    this.content('更新失败!');
                                }
                            },
                            error: function () {
                                this.content('更新失败!');
                            }
                        });
                        return false;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                    }
                });
                d.show();
                break;
            default:
                var d = dialog({
                    title: '提示',
                    width: 200,
                    content: '您将删除记录',
                    okValue: '确定',
                    ok: function () {
                        this.title('删除中...');

                        $.ajax({
                            url: "{:U('Index/del')}",
                            type: 'post',
                            dataType: 'json',
                            timeout: 80000,
                            data: {
                                id: id
                            },
                            success: function (data) {
                                if (data.status) {
                                    window.location.reload();
                                }
                                else {
                                    this.content('删除失败!');
                                }
                            },
                            error: function () {
                                this.content('删除失败!');
                            }
                        });
                        return false;
                    },
                    cancelValue: '取消',
                    cancel: function () {
                    }
                });
                d.show();
                break
        }
    }
</script>

<include file="Public/footer"/>